package com.e3.basdoc.corp.model;

import java.util.Date;

import com.e3.basdoc.region.model.RegionModel;
import com.e3.template.model.TGFTreeModel;

public class CorpModel extends TGFTreeModel implements CorpFields {

	private static final long serialVersionUID = 4879623381700040927L;

	private RegionModel region;

	private Long regionId;

	private Long currencyId;

	// 基本信息
	public String getCode() {
		return get(CorpFields.CODE);
	}

	public void setCode(String code) {
		set(CorpFields.CODE, code);
	}

	public String getName() {
		return get(CorpFields.NAME);
	}

	public void setName(String name) {
		set(CorpFields.NAME, name);
	}

	public String getShortName() {
		return get(CorpFields.SHORT_NAME);
	}

	public void setShortName(String shortName) {
		set(CorpFields.SHORT_NAME, shortName);
	}

	public String getType() {
		return get(CorpFields.TYPE);
	}

	public void setType(String type) {
		set(CorpFields.TYPE, type);
	}

	public CorpModel getParentCorp() {
		return get(CorpFields.PARENT_CORP);
	}

	public void setParentCorp(CorpModel parentCorp) {
		set(CorpFields.PARENT_CORP, parentCorp);
		if(parentCorp!=null){
			setParentId(parentCorp.getId());
		}
	}

	public Long getRegionId() {
		if(this.regionId==null){
			return getRefModelId(CorpModel.REGION);
		}
		return this.regionId;
	}

	public void setRegionId(Long regionId) {
		this.regionId = regionId;
	}

	public RegionModel getRegion() {
		return get(CorpFields.REGION);
	}

	public void setRegion(RegionModel region) {
		set(CorpFields.REGION, region);
		if(region!=null){
			setRegionId(region.getId());
		}
	}

	public String getBusinessAddress() {
		return get(CorpFields.BUSINESS_ADDRESS);
	}

	public void setBusinessAddress(String businessAddr) {
		set(CorpFields.BUSINESS_ADDRESS, businessAddr);
	}

	public String getContactAddress() {
		return get(CorpFields.CONTACT_ADDRESS);
	}

	public void setContactAddress(String contactAddr) {
		set(CorpFields.CONTACT_ADDRESS, contactAddr);
	}

	public String getFax() {
		return get(CorpFields.FAX);
	}

	public void setFax(String fax) {
		set(CorpFields.FAX, fax);
	}

	public String getZipcode() {
		return get(CorpFields.ZIPCODE);
	}

	public void setZipcode(String zipcode) {
		set(CorpFields.ZIPCODE, zipcode);
	}

	public String getTelphone() {
		return get(CorpFields.TELPHONE);
	}

	public void setTelphone(String telphone) {
		set(CorpFields.TELPHONE, telphone);
	}

	public String getEmail() {
		return get(CorpFields.EMAIL);
	}

	public void setEmail(String email) {
		set(CorpFields.EMAIL, email);
	}

	public String getRemark() {
		return get(CorpFields.REMARK);
	}

	public void setRemark(String remark) {
		set(CorpFields.REMARK, remark);
	}

	// 注册信息
	public String getRegisterAddress() {
		return get(CorpFields.REGISTER_ADDRESS);
	}

	public void setRegisterAddress(String registerAddress) {
		set(CorpFields.REGISTER_ADDRESS, registerAddress);
	}

	public String getLegalPerson() {
		return get(CorpFields.LEGAL_PERSON);
	}

	public void setLegalPerson(String legalPerson) {
		set(CorpFields.LEGAL_PERSON, legalPerson);
	}

	public String getLegalPersonIdcard() {
		return get(CorpFields.LEGAL_PERSON_IDCARD);
	}

	public void setLegalPersonIdcard(String legalPersonIdcard) {
		set(CorpFields.LEGAL_PERSON_IDCARD, legalPersonIdcard);
	}

	public String getRegisterNo() {
		return get(CorpFields.REGISTER_NO);
	}

	public void setRegisterNo(String registerNo) {
		set(CorpFields.REGISTER_NO, registerNo);
	}

	public String getTaxNo() {
		return get(CorpFields.TAX_NO);
	}

	public void setTaxNo(String taxNo) {
		set(CorpFields.TAX_NO, taxNo);
	}

	public String getContactPerson() {
		return get(CorpFields.CONTACT_PERSON);
	}

	public void setContactPerson(String contactPerson) {
		set(CorpFields.CONTACT_PERSON, contactPerson);
	}

	public String getContactWay() {
		return get(CorpFields.CONTACT_WAY);
	}

	public void setContactWay(String contactWay) {
		set(CorpFields.CONTACT_WAY, contactWay);
	}

	public Date getFoundTime() {
		return get(CorpFields.FOUND_TIME);
	}

	public void setFoundTime(Date foundTime) {
		set(CorpFields.FOUND_TIME, foundTime);
	}

	public Date getRegisterStartTime() {
		return get(CorpFields.REGISTER_START_TIME);
	}

	public void setRegisterStartTime(Date registerStartTime) {
		set(CorpFields.REGISTER_START_TIME, registerStartTime);
	}

	public Date getRegisterEndTime() {
		return get(CorpFields.REGISTER_END_TIME);
	}

	public void setRegisterEndTime(Date registerEndTime) {
		set(CorpFields.REGISTER_END_TIME, registerEndTime);
	}

	public Long getCurrencyId() {
		if(currencyId==null){
			return getRefModelId(CorpModel.CURRENCY);
		}
		return currencyId;
	}

	public void setCurrencyId(Long currencyId) {
		this.currencyId = currencyId;
	}

	public String getTaxpayerType() {
		return get(CorpFields.TAXPAYER_TYPE);
	}

	public void setTaxpayerType(String taxpayerType) {
		set(CorpFields.TAXPAYER_TYPE, taxpayerType);
	}

	// 其他信息
	public boolean getEstablishAccount() {
		return (Boolean)get(CorpFields.ESTABLISH_ACCOUNT);
	}

	public void setEstablishAccount(boolean establishAccount) {
		set(CorpFields.ESTABLISH_ACCOUNT, establishAccount);
	}

	public String getMaxUsers() {
		return (String)get(CorpFields.MAX_USERS);
	}

	public void setMaxUsers(String maxUsers) {
		set(CorpFields.MAX_USERS, maxUsers);
	}

	public String getMaxBranchs() {
		return get(CorpFields.MAX_BRANCHS);
	}

	public void setMaxBranchs(String maxBranchs) {
		set(CorpFields.MAX_BRANCHS, maxBranchs);
	}

	public Date getStartTime() {
		return get(CorpFields.START_TIME);
	}

	public void setStartTime(Date startTime) {
		set(CorpFields.START_TIME, startTime);
	}

	public Date getEndTime() {
		return get(CorpFields.END_TIME);
	}

	public void setEndTime(Date endTime) {
		set(CorpFields.END_TIME, endTime);
	}

	public String toString() {
		return getName();
	}

	public String[] getModelFields() {
		return CorpFields.fieldNames;
	}

	@Override
	public String getParentFiledName() {
		return CorpFields.PARENT_CORP;
	}

}
